/*******************************************************
 * @作者: zhaohua
 * @日期: 2012-7-11
 * @描述: 用于在非Activity周期中，展示Dialog的一个载体.
 * @声明: copyrights reserved by Petfone 2007-2011
*******************************************************/
package com.android.pagemarket.ui.activity.main;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;

import com.android.pagemarket.ui.activity.base.TemplateActivity;
import com.android.pagemarket.ui.widget.TitleBar;

public class DialogShowActivity extends TemplateActivity
{
	public static final int DIALOG_NETWORK=0x3302;
	public static final String TAG_DIALOG_ID = "dialog_id";
	public static final String TAG_PARAM = "param";
	// 窗口id
	private int dialog_id = 0;
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);	
		dialog_id = getIntent().getIntExtra(TAG_DIALOG_ID, 0);
		if(dialog_id == 0)
		{
			finish();
			return;
		}
	}
	
	@Override
	protected void setupTitleBar(TitleBar titleBar)
	{
	    titleBar.setVisibility(View.GONE);
	}
	
	@Override
	protected void onResume()
	{
		super.onResume();
		showDialog();
	}
	
	private void showDialog()
	{
		switch(dialog_id)
		{			
			case DIALOG_NETWORK:
			{
			    showNoNetworkDialog1();
			    break;
			}
		}
	}
	
	private void showNoNetworkDialog1()
	{
	    showDialogActivity("网络设置提示", "网络连接不可用,是否进行设置?", "取消", "设置", 
        new DialogInterface.OnClickListener()
        {           
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
              startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
            }
        });
	}
	
	public static void startActivity(Context context, int dialogId)
	{
		Intent it = new Intent(context, DialogShowActivity.class);
		it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		it.putExtra(TAG_DIALOG_ID, dialogId);
		context.startActivity(it);
	}
}